package com.demo.batch.job;

import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.NonTransientResourceException;
import org.springframework.batch.item.ParseException;
import org.springframework.batch.item.UnexpectedInputException;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 *
 * @author
 * @since
 */
@Component
@Slf4j
public class DemoItemReader implements ItemReader<String> {

  @Override
  public String read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
    String s = UUID.randomUUID().toString();
    log.info(" ========= DemoItemReader execute : {}", s);
    return "a".equals(s.substring(0,1)) ? null : s;
  }


}
